CFLAGS = -Wall -fpic -coverage -lm

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

testdominion: testdominion.c testdominion.h dominion.c rngs.c
	gcc -o testdominion -g testdominion.c dominion.c rngs.c $(CFLAGS)

testdominion.out: testdominion
	rm -f testdominion.out
	echo "Results for running tests on dominion with random # of players & kingdom cards:" > testdominion.out
	testdominion -n 10000 >> testdominion.out
	gcov dominion.c >> testdominion.out

gameResults.out: testdominion
	rm -f gameResults.out
	echo "Running dominion game with random # of players and kingdom cards:" > gameResults.out
	testdominion -d >> gameResults.out

unittestresults.out: unittest1.c unittest2.c unittest3.c unittest4.c cardtest1.c cardtest2.c cardtest3.c cardtest4.c dominion.c rngs.c
	echo "Result for running dominion unit and cardEffect tests:" > unittestresults.out

	echo "unittest1.c:" >> unittestresults.out
	gcc -o unittest1 unittest1.c dominion.c rngs.c  $(CFLAGS)
	unittest1 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "unittest2.c:" >> unittestresults.out
	gcc -o unittest2 unittest2.c dominion.c rngs.c $(CFLAGS)
	unittest2 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "unittest3.c:" >> unittestresults.out
	gcc -o unittest3 unittest3.c dominion.c rngs.c $(CFLAGS)
	unittest3 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "unittest4.c:" >> unittestresults.out
	gcc -o unittest4 unittest4.c dominion.c rngs.c $(CFLAGS)
	unittest4 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "cardtest1.c:" >> unittestresults.out
	gcc -o cardtest1 cardtest1.c dominion.c rngs.c $(CFLAGS)
	cardtest1 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "cardtest2.c:" >> unittestresults.out
	gcc -o cardtest2 cardtest2.c dominion.c rngs.c $(CFLAGS)
	cardtest2 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "cardtest3.c:" >> unittestresults.out
	gcc -o cardtest3 cardtest3.c dominion.c rngs.c $(CFLAGS)
	cardtest3 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

	echo "cardtest4.c:" >> unittestresults.out
	gcc -o cardtest4 cardtest4.c dominion.c rngs.c $(CFLAGS)
	cardtest4 >> unittestresults.out
	gcov dominion.c >> unittestresults.out

randomtestadventurer: randomtestadventurer.c dominion.c rngs.c
	gcc -o randomtestadventurer -g randomtestadventurer.c dominion.c rngs.c $(CFLAGS)

randomtestcard: randomtestcard.c dominion.c rngs.c
	gcc -o randomtestcard -g randomtestcard.c dominion.c rngs.c $(CLFAGS)

randomtestcard.out: randomtestcard
	rm -f randomtestcard.out
	echo "Result for running dominion random test on mine card:" > randomtestcard.out
	echo "randomtestcard.c:" >> randomtestcard.out
	randomtestcard >> randomtestcard.out
	gcov dominion >> randomtestcard.out

randomtestadventurer.out: randomtestadventurer
	rm -f randomtestadventurer.out
	echo "Result for running dominion random test on adventurer card:" > randomtestadventurer.out
	echo "randomtestadventurer.c:" >> randomtestadventurer.out
	randomtestadventurer >> randomtestadventurer.out
	gcov dominion >> randomtestadventurer.out

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c randomtestadventurer.out randomtestcard.out unittestresults.out
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o unittestresults.out randomtestadventurer.out randomtestcard.out randomtestadventurer.o randomtestcard.o playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard\
	testBuyCard.exe badTestDrawCard badTestDrawCard.exe unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4 *.gcov *.gcda *.gcno *.so testdominion *~ testdominion.out gameResults.out
